#include "main.h"

/* Delay function */
void Delay_ms(int n)
{
	unsigned int i, j;
	
	for(i = 1; i <= n; i++)
	{
		for(j = 1; j <= 48000; j++);
	}		
}

void RAM_WriteData(uint8_t *Address, uint8_t *Data, uint32_t Size){
	for(;Size!=0;Size--){
		*(__IO uint8_t*)Address = *Data; 
		Data++;
		Address++;
	}
}
void StartApplication(uint32_t AppAddr, uint32_t EntryPointImage)
{
	typedef void (*pFunction)(void);
	pFunction Jump_To_Application;
	
	/*Remap Vector Table*/
	SCB->VTOR = AppAddr;
	/*Jump to user application*/
	Jump_To_Application = (pFunction) EntryPointImage;
	Jump_To_Application();
}
void JumpToApplication(uint32_t AppAddr){
	typedef void(*pFunc)(void);
	pFunc JumpApp;
	uint32_t EntryPoint;
	/*Remap Vector Table*/
	SCB->VTOR = AppAddr;
	/*Get value entry point image of application*/
	EntryPoint  = *(__IO uint32_t*)(AppAddr + 4);
	/*Jump tp application*/
	JumpApp = (pFunc)EntryPoint;
	JumpApp();
}